<!DOCTYPE html>
 <html>
 <head>
 <meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
 <% include("/WEB-INF/view/console/common/css.html"){}	%>
 <% include("/WEB-INF/view/console/common/js.html"){} 	%>
 <title></title>
 </head>
 <body> <nav class="navbar navbar-default navbar-fixed-top site-navbar" >
  <div class="navbar-header">
 <a class="navbar-brand" href="#">boProxyShippingAddress</a>
 </div>
  </nav>
 <form name="boProxyShippingAddress_form"  id="boProxyShippingAddress_form" class="form-horizontal" style="margin-top: 60px;">
   <div class="form-group" >
 <label class="col-sm-2 control-label">用户id</label>
 <div class="col-sm-6">
 <input  type="text"  name="prpxyId" id="prpxyId" class="form-control" check-type="required" value='${boProxyShippingAddress.prpxyId!}' >
 </div>
  </div>
 <div class="form-group" >
 <label class="col-sm-2 control-label">收件人</label>
 <div class="col-sm-6">
 <input  type="text"  name="consigneeName" id="consigneeName" class="form-control" check-type="required" value='${boProxyShippingAddress.consigneeName!}' >
 </div>
  </div>
 <div class="form-group" >
 <label class="col-sm-2 control-label">收件人电话</label>
 <div class="col-sm-6">
 <input  type="text"  name="consigneePhone" id="consigneePhone" class="form-control" check-type="required" value='${boProxyShippingAddress.consigneePhone!}' >
 </div>
  </div>
 <div class="form-group" >
 <label class="col-sm-2 control-label">邮编</label>
 <div class="col-sm-6">
 <input  type="text"  name="shippingPostcode" id="shippingPostcode" class="form-control" check-type="required" value='${boProxyShippingAddress.shippingPostcode!}' >
 </div>
  </div>
<!-- <div class="form-group" >
 <label class="col-sm-2 control-label">收货区域</label>
 <div class="col-sm-6">
 <input  type="text"  name="shippingArea" id="shippingArea" class="form-control" check-type="required" value='${boProxyShippingAddress.shippingArea!}' >
 </div>
  </div>-->
 <div class="form-group" >
 <label class="col-sm-2 control-label">地址</label>
 <div class="col-sm-6">
  <select id="shippingProvince" onChange="loadNext(this);"><option value="">请选择...</option></select>
  <select id="shippingCity" onChange="loadNext(this);"><option value="">请选择...</option></select>
  <select id="shippingCounty" onChange="loadNext(this);"><option value="">请选择...</option></select>
 </div>
  </div>
  <script type="text/javascript">
   $(function ($) {
    getAddress("shippingProvince",0);
   });
   function getAddress(hid,pid) {
    $.post("${ctxPath}/console/common/getNext/"+pid,function(data) {
     var cityHtml='<option value="">请选择...</option>';
     var arrayAddress = data.data;
     for(var key in arrayAddress){
      cityHtml += "<option value='" + key + "'>" + arrayAddress[key] + "</option>";
     }
     $("#"+hid).html(cityHtml);
    });
   }
   function loadNext(obj){
    var id= $(obj).val();
    var hid = $(obj).attr("id");
    switch (hid){
     case "shippingProvince":
      getAddress("shippingCity",id);
      break;
     case "shippingCity":
      getAddress("shippingCounty",id);
      break;
     default:
      break;
    };
   }
  </script>
 <div class="form-group" >
 <label class="col-sm-2 control-label">详细地址</label>
 <div class="col-sm-6">
 <input  type="text"  name="shippingDetailAddress" id="shippingDetailAddress" class="form-control" check-type="required" value='${boProxyShippingAddress.shippingDetailAddress!}' >
 </div>
  </div>
 <div class="form-group" >
 <label class="col-sm-2 control-label">是否是默认地址</label>
 <div class="col-sm-6">
 <label><input checked='checked' auto_name='boProxyShippingAddress_defaultAddress' type="radio"  name="defaultAddress" value="0"/>否</label>
 <label><input  auto_name='boProxyShippingAddress_defaultAddress' type="radio"  name="defaultAddress" value="1"/>是</label>
  
 </div>
  </div>
 	<script type="text/javascript">
       $(function($){
       $('input[auto_name="boProxyShippingAddress_defaultAddress"]').each(function(){
       if('${boProxyShippingAddress.defaultAddress!}'==this.value){ 
             $(this).attr('checked','checked');
            }
           });
 	    });
 	</script> 
 
   <input type='hidden' name='shippingAddressId' id='shippingAddressId' value='${boProxyShippingAddress.shippingAddressId!}'><input type='hidden' name='common_token' id='common_token' value='${common_token!}'>
 <div class="form-group" style="margin-bottom: 60px;"></div>
 </form>
 <script type="text/javascript">
 $(function($) {
    /*开启表单验证*/
 	$("#boProxyShippingAddress_form").validation();
 });
 /*保存*/
 function saveZqForm(){
    if ($("#boProxyShippingAddress_form").valid() == false) {
 	    return false;
    }
    var formObject=new Object();
    formObject.prpxyId=$('#prpxyId').val()==''?null:$('#prpxyId').val(); 
 formObject.consigneeName=$('#consigneeName').val()==''?null:$('#consigneeName').val(); 
 formObject.consigneePhone=$('#consigneePhone').val()==''?null:$('#consigneePhone').val(); 
 formObject.shippingPostcode=$('#shippingPostcode').val()==''?null:$('#shippingPostcode').val(); 
/* formObject.shippingArea=$('#shippingArea').val()==''?null:$('#shippingArea').val(); */
 formObject.shippingProvince=$('#shippingProvince').val()==''?null:$('#shippingProvince').val(); 
 formObject.shippingCity=$('#shippingCity').val()==''?null:$('#shippingCity').val(); 
 formObject.shippingCounty=$('#shippingCounty').val()==''?null:$('#shippingCounty').val(); 
 formObject.shippingDetailAddress=$('#shippingDetailAddress').val()==''?null:$('#shippingDetailAddress').val(); 
 formObject.defaultAddress=($('input[name="defaultAddress"]:checked').val()==''?null:$('input[name="defaultAddress"]:checked').val()); 
 formObject.shippingAddressId=$('#shippingAddressId').val()==''?null:$('#shippingAddressId').val(); 
 
    var formObjectJson = JSON.stringify(formObject);
    $.post("${ctxPath}/console/bo_proxy_shipping_address/save",
     {
           formObjectJson :formObjectJson,
 	   table_name :'boProxyShippingAddress',
 	   common_token :$("#common_token").val()
     }, function(data) {
        $.confirm({
              title: '提示',
              content: data.message,
              autoClose: 'cancelAction|3000',
              escapeKey: 'cancelAction',
              buttons: {
                  cancelAction: {
                      text: '确定',
                      action: function () {
            parent.$("#boProxyShippingAddress").bootstrapTable("refresh");
            parent.art.dialog.get('id-dialog-boProxyShippingAddress').close();
                      }
                  }
              }
 		});
     });
 }
 </script>
 <nav class="navbar navbar-default navbar-fixed-bottom site-navbar" >
 <div class="container" style="padding-top:10px;padding-bottom:10px;">
 <div class="nav navbar-nav navbar-right">
 <a href="#" class="btn btn-success"  onclick='saveZqForm()'>保存 </a>
  </div>
  </div>
  </nav>
 </body>
